package cn.csc.module.product.dal.mysql.attr;

import cn.csc.framework.common.pojo.PageResult;
import cn.csc.framework.mybatis.core.mapper.BaseMapperX;
import cn.csc.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.csc.module.product.controller.admin.attr.vo.AttrExportReqVO;
import cn.csc.module.product.controller.admin.attr.vo.AttrPageReqVO;
import cn.csc.module.product.dal.dataobject.attr.AttrDO;
import org.apache.ibatis.annotations.Mapper;

import java.math.BigInteger;
import java.util.List;

/**
 * 属性信息 Mapper
 *
 * @author liuchuang
 */
@Mapper
public interface AttrMapper extends BaseMapperX<AttrDO> {

    default PageResult<AttrDO> selectPage(AttrPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<AttrDO>()
                .eqIfPresent(AttrDO::getShopId, reqVO.getShopId())
                .likeIfPresent(AttrDO::getName, reqVO.getName())
                .eqIfPresent(AttrDO::getDesc, reqVO.getDesc())
                .eqIfPresent(AttrDO::getSearchType, reqVO.getSearchType())
                .eqIfPresent(AttrDO::getAttrType, reqVO.getAttrType())
                .betweenIfPresent(AttrDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(AttrDO::getId));
    }

    default List<AttrDO> selectList(AttrExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<AttrDO>()
                .eqIfPresent(AttrDO::getShopId, reqVO.getShopId())
                .likeIfPresent(AttrDO::getName, reqVO.getName())
                .eqIfPresent(AttrDO::getDesc, reqVO.getDesc())
                .eqIfPresent(AttrDO::getSearchType, reqVO.getSearchType())
                .eqIfPresent(AttrDO::getAttrType, reqVO.getAttrType())
                .betweenIfPresent(AttrDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(AttrDO::getId));
    }



    AttrDO getByAttrId(BigInteger attrId);

}
